package com.lgt_enterprise_android.view.pages.me;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.amap.api.maps2d.AMap;
import com.amap.api.maps2d.model.LatLng;
import com.amap.api.maps2d.model.Marker;
import com.lgt_enterprise_android.R;

public class MyInfoWindow implements AMap.InfoWindowAdapter {
    private Context context;
    private LatLng latLng;
    private TextView userText;
    private String userInfo;
    private TextView deviceText;
    private String deviceInfo;
    private View view;

    public MyInfoWindow(Context context) {
        this.context = context;
    }

    private void initData(Marker marker) {
        latLng = marker.getPosition();
        deviceInfo = marker.getSnippet();
        userInfo = marker.getTitle();
    }

    private View initView(int type) {
        if (type == 1) {
            view = LayoutInflater.from(context).inflate(R.layout.item_map_window, null);
        }
//        else if (type == 2) {
//            view = LayoutInflater.from(context).inflate(R.layout.my_infowindow_grey, null);
//        }
//        userText = view.findViewById(R.id.user_info);
//        deviceText = view.findViewById(R.id.device_info);

        userText.setText(userInfo);
        deviceText.setText(deviceInfo);
        return view;
    }

    @Override
    public View getInfoWindow(Marker marker) {

        initData(marker);
        View view;
        if ((int) marker.getObject() == 1) {
            view = initView(1);
        } else if ((int) marker.getObject() == 2) {
            view = initView(2);
        } else {
            view = initView(1);
        }
        return view;
    }

    @Override
    public View getInfoContents(Marker marker) {
        return null;
    }

}
